import com.alibaba.fastjson.annotation.JSONField;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Objects;

import static org.apache.commons.beanutils.BeanUtils.copyProperties;

/**
 * 条文详情
 *
 * @author shun
 */
public class Provision {
    /**
     * 规范编码
     */
    @JSONField(ordinal = 0)
    private String standard;
    /**
     * 条文编码
     */
    @JSONField(ordinal = 1)
    private String sn;
    /**
     * 是否为条文解释
     */
    @JSONField(ordinal = 2)
    private boolean isExplanatory=false;
    /**
     * 是否为强制条文
     */
    @JSONField(ordinal = 3)
    private boolean isEnforced=false;
    /**
     * 条文内容
     */
    @JSONField(ordinal = 4)
    private ArrayList<String> content = new ArrayList<>();

    public Provision() {
    }

    /**
     * 拷贝对象
     *
     * @return 新的 Provision 对象
     */
    public Provision duplicate() {
        Provision tmp = new Provision();
        try {
            copyProperties(tmp, this);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return tmp;
    }

    @Override
    public String toString() {
        return "Provision{" +
                "code='" + standard + '\'' +
                ", sn='" + sn + '\'' +
                ", isExplanatory=" + isExplanatory +
                ", isEnforced=" + isEnforced +
                ", content=" + content +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Provision provision = (Provision) o;
        return Objects.equals(standard, provision.standard) &&
                Objects.equals(sn, provision.sn);
    }

    @Override
    public int hashCode() {
        return Objects.hash(standard, sn);
    }

    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    public ArrayList<String> getContent() {
        return content;
    }

    public void setContent(ArrayList<String> content) {
        this.content = content;
    }

    public boolean isExplanatory() {
        return isExplanatory;
    }

    public void setExplanatory(boolean explanatory) {
        isExplanatory = explanatory;
    }

    public void setStandard(String standard) {
        this.standard = standard;
    }

    public String getStandard() {
        return standard;
    }

    public boolean isEnforced() {
        return isEnforced;
    }

    public void setEnforced(boolean enforced) {
        isEnforced = enforced;
    }
}
